﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft.Framework.Reflection
{
    /// <summary>
    /// 原理：使用动态编译生成一个包含目标对象的BeanMap.继承IBeanMap.
    /// 
    /// 如果返回的是对象，则仍然保持对象，而不会转化为BeanMap
    /// </summary>
    public interface IBeanMap : IDisposable
    {
        /// <summary>
        /// 是否包含field
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool ContainsKey(string key);

        /// <summary>
        /// 判断是否有值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool HasValue(string key);

        /// <summary>
        /// 返回指定类型的对象
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object GetValue(string key);

        /// <summary>
        /// 尝试获取值 如果不存在 返回默认空值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object TryGetValue(string key, Type type);

        /// <summary>
        /// 设置值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        void SetValue(string key, object value);

        /// <summary>
        /// 清空指定的值
        /// </summary>
        /// <param name="key"></param>
        bool RemoveValue(string key);

        /// <summary>
        /// 获取键集合 用于遍历
        /// </summary>
        string[] Keys { get;}

        /// <summary>
        /// 返回对象
        /// </summary>
        object GetBean();

        /// <summary>
        /// 范型返回值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T GetBean<T>();

        /// <summary>
        /// 克隆
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T Clone<T>();

        /// <summary>
        /// 大小
        /// </summary>
        int Count { get;}
    }
}
